<h1 class="title">Search tasks</h1>
<%= render :partial => 'root/search_form' %>

<% if @tasks && @tasks.size() != 0 %>
<a href="/search/export/tasks.csv?<%= request.query_string %>">Export to CSV</a><br /><br />
<table class="tabular" style="width: 80%">
 <tr class="header">
  <th>#</th>
  <th>Subject</th>
  <th>Project</th>
  <th>Priority</th>
  <th>Status</th>
  <th>Created</th>
  <th>Requestor</th>
  <th>Owner</th>
  <th>Time worked</th>
  <th>Time left</th>
  <th></th>
 </tr>
<% for task in @tasks %>
 <tr>
  <td><%= link_to task.task_id, { :controller => "task", :action => "show", :id => task.task_id }  %></td>
  <td><%= link_to task.subject, { :controller => "task", :action => "show", :id => task.task_id }  %></td>
  <td><%= link_to task.project.name, { :controller => "project", :action => "show", :id => task.project.project_id }  %></td>
  <td><%= task.priority %>/10</td>
  <td><%= task.status.name %></td>
  <td><%= task.created.strftime('%F %T') %></td>
  <td><%= task.requestor %></td>
  <td><% if task.user %><%= link_to task.user.username, {:controller => 'user', :action => 'show', :id => task.owner } %><% else %>Nobody<% end %></td>
  <td><%= task.time_worked %></td>
  <td><%= task.estimated_time - task.time_worked %></td>
  <td>
   <% if task.owner == nil %><%= link_to 'Take', {:controller => 'task', :action => 'take', :id => task.task_id } %>
   <% else %> 
     <% if task.owner != session[:user].user_id %><%= link_to 'Steal', {:controller => 'task', :action => 'steal', :id => task.task_id } %><% end %>
   <% end %></td>
 </tr> 
<% end %>
</table>
<% else %>
 <% if params[:do] != nil %>No results.<% end %>
<% end %>
